package com.oocl.o2o.client.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@GenericGenerator(name="merchant_id_generator",strategy="uuid")
public class Merchant {
	@Id
	@GeneratedValue(generator="merchant_id_generator")
	@Column(columnDefinition="char(32)")
	// uuid id
	private String id;
	private String username;
	private String password;
	// the relative url of idCard
	@Column(name="id_card")
	private String idCard;
	//the relative url of portrait
	private String portrait;
	private String address;
	// follow list is read only, but its element can be write
	
	
	@OneToMany(mappedBy = "merchant", fetch=FetchType.EAGER)
	@JsonIgnore
	private List<Food> foods = new ArrayList<Food>();
	
	
	@OneToMany(mappedBy = "merchant")
	@JsonIgnore
	private List<Commentary> commentaries = new ArrayList<Commentary>();
	@JsonIgnore
	@OneToMany(mappedBy = "merchant")
	private List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
	
	@OneToMany(mappedBy = "merchant")
	@JsonIgnore
	private List<Advertisement> advertisements = new ArrayList<Advertisement>();

	public Merchant() {
	}

	public Merchant( String username, String password, String idCard, String portrait, String address) {
		this.username = username;
		this.password = password;
		this.idCard = idCard;
		this.portrait = portrait;
		this.address = address;
	}

	public String getId() {
		return id;
	}


	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getPortrait() {
		return portrait;
	}

	public void setPortrait(String portrait) {
		this.portrait = portrait;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public List<Food> getFoods() {
		return foods;
	}



	public void setId(String id) {
		this.id = id;
	}

	public void setFoods(List<Food> foods) {
		this.foods = foods;
	}

	public void setCommentaries(List<Commentary> commentaries) {
		this.commentaries = commentaries;
	}

	public void setOrderInfos(List<OrderInfo> orderInfos) {
		this.orderInfos = orderInfos;
	}

	public void setAdvertisements(List<Advertisement> advertisements) {
		this.advertisements = advertisements;
	}

	public List<OrderInfo> getOrderInfos() {
		return orderInfos;
	}

	public List<Commentary> getCommentaries() {
		return commentaries;
	}

	public List<Advertisement> getAdvertisements() {
		return advertisements;
	}

}
